package com.compunit.composite.core.interfaces;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;

import javax.naming.OperationNotSupportedException;

/**
 * <code>IExporter</code> defines the generic interface
 * of an exporter unit that is capable of exporting its
 * cached data to a given destination file.
 * <p>
 * <code>IExporter</code> first caches all information
 * internally for later export. A cache clean up can
 * be done via the <code>cleanup</code> method to erase
 * all the cached data.
 * <p>
 * <code>IExporter</code> is meant to be used in a
 * strictly single-threaded environment. There is no
 * concurrency support at all.
 *
 * @author Yi Wang (Neakor)
 * @version Creation date: 11-12-2009 19:04 EST
 * @version Modified date: 12-05-2009 13:58 EST
 */
public interface IExporter {

	/**
	 * Export the cached data as to the given destination.
	 * @param dir The <code>URL</code> representing
	 * the destination file directory.
	 * @param filename The <code>String</code> file name
	 * of the destination file including extension.
	 * @throws URISyntaxException If given URL is invalid.
	 * @throws IOException If file handling failed.
	 * @throws OperationNotSupportedException If this export
	 * operation is not supported by the implementation.
	 */
	public void export(final URL dir, final String filename) throws URISyntaxException, IOException, OperationNotSupportedException;
	
	/**
	 * Export the cached data as to the given destination.
	 * @param dir The <code>String</code> representing
	 * the destination file directory.
	 * @param filename The <code>String</code> file name
	 * of the destination file including extension.
	 * @throws URISyntaxException If given URL is invalid.
	 * @throws IOException If file handling failed.
	 * @throws OperationNotSupportedException If this export
	 * operation is not supported by the implementation.
	 */
	public void export(final String dir, final String filename) throws URISyntaxException, IOException, OperationNotSupportedException;
	
	/**
	 * Cleanup all the cached information.
	 */
	public void cleanup();
	
	/**
	 * Check if there is any data to be exported.
	 * @return <code>true</code> if there is data cached
	 * to be exported. <code>false</code> otherwise.
	 */
	public boolean isEmpty();
}
